﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SIGCBI.Entities;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace SIGCBI.Repository.Mapping
{
    public class HabitacionMap : EntityTypeConfiguration<HABITACION>
    {
        public HabitacionMap()
        {
            //key
            this.HasKey(e => e.ID);

            //propiedades
            this.Property(e => e.ID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(e => e.Nombre)
                .HasMaxLength(200)
                .IsRequired();

            this.Property(e => e.Tipo)
                .HasMaxLength(200)
                .IsRequired();

            this.Property(e => e.Tarifa)
                .HasPrecision(18, 2)
                .IsRequired();

            this.Property(e => e.Estado)
                .IsRequired();

            //tabla
            this.ToTable("HABITACION");

            this.HasMany(e => e.ALQUILERs)
                .WithRequired()
                .HasForeignKey(p => p.IdHabitacion)
                .WillCascadeOnDelete(false);

            this.HasMany(e => e.SERVICIOs)
                .WithRequired()
                .HasForeignKey(p => p.IdHabitacion)
                .WillCascadeOnDelete(false);
        }
    }
}
